import route from '../internal/mixins/route';

export default {
  name: 'co-list-item',
  mixins: [route],
  props: {
    button: Boolean,
    link: Boolean,
    itemClass: String
  },
  render (h) {
    return h('li', {
      on: this.$listeners
    }, [
      this.$slots.prev,
      h(this.to ? 'router-link' : this.button ? 'a' : 'div', {
        staticClass: 'co-list-item ' + (this.itemClass || ''),
        class: {
          'co-list-item--button': this.button || this.link
        },
        attrs: {
          ...this.$attrs,
          href: this.href
        },
        props: {
          ...this.generateRouteProps()
        }
      }, [
        this.$slots.default,
        h('div', {
          staticClass: 'co-list-item-right'
        }, [
          this.$slots.right,
          this.link ? h('co-icon-arrow-right', {
            staticClass: 'co-list-item-link'
          }) : null
        ])
      ]),
      this.$slots.next
    ]);
  }
};
